
#include "Mapper118.h"
#include "MMC3.h"

SETUP_STATIC_INES_MAPPER_REGISTRAR(118)

// TODO: mirroring crap

//------------------------------------------------------------------------------
// Name: Mapper118
//------------------------------------------------------------------------------
Mapper118::Mapper118() : mapper_(new MMC3B) {
}

//------------------------------------------------------------------------------
// Name: ~Mapper118
//------------------------------------------------------------------------------
Mapper118::~Mapper118() {
	delete mapper_;
}

//------------------------------------------------------------------------------
// Name: name
//------------------------------------------------------------------------------
std::string Mapper118::name() const {
	return "TxSROM";
}

//------------------------------------------------------------------------------
// Name:
//------------------------------------------------------------------------------
uint8_t Mapper118::read_6(uint16_t address) {
	return mapper_->read_6(address);
}

//------------------------------------------------------------------------------
// Name:
//------------------------------------------------------------------------------
uint8_t Mapper118::read_7(uint16_t address) {
	return mapper_->read_7(address);
}

//------------------------------------------------------------------------------
// Name:
//------------------------------------------------------------------------------
void Mapper118::write_6(uint16_t address, uint8_t value) {
	mapper_->write_6(address, value);
}

//------------------------------------------------------------------------------
// Name:
//------------------------------------------------------------------------------
void Mapper118::write_7(uint16_t address, uint8_t value) {
	mapper_->write_7(address, value);
}

//------------------------------------------------------------------------------
// Name:
//------------------------------------------------------------------------------
void Mapper118::write_8(uint16_t address, uint8_t value) {
	mapper_->write_8(address, value);
}

//------------------------------------------------------------------------------
// Name:
//------------------------------------------------------------------------------
void Mapper118::write_9(uint16_t address, uint8_t value) {
	mapper_->write_9(address, value);
}

//------------------------------------------------------------------------------
// Name:
//------------------------------------------------------------------------------
void Mapper118::write_a(uint16_t address, uint8_t value) {
	switch(address & 0x0001) {
	case 0x0000:
		// ignore these mirror writes, it is handled differently
		break;
	case 0x0001:
		mapper_->write_a(address, value);
		break;
	}
}

//------------------------------------------------------------------------------
// Name:
//------------------------------------------------------------------------------
void Mapper118::write_b(uint16_t address, uint8_t value) {
	mapper_->write_b(address, value);
}

//------------------------------------------------------------------------------
// Name:
//------------------------------------------------------------------------------
void Mapper118::write_c(uint16_t address, uint8_t value) {
	mapper_->write_c(address, value);
}

//------------------------------------------------------------------------------
// Name:
//------------------------------------------------------------------------------
void Mapper118::write_d(uint16_t address, uint8_t value) {
	mapper_->write_d(address, value);
}

//------------------------------------------------------------------------------
// Name:
//------------------------------------------------------------------------------
void Mapper118::write_e(uint16_t address, uint8_t value) {
	mapper_->write_e(address, value);
}

//------------------------------------------------------------------------------
// Name:
//------------------------------------------------------------------------------
void Mapper118::write_f(uint16_t address, uint8_t value) {
	mapper_->write_f(address, value);
}

//------------------------------------------------------------------------------
// Name:
//------------------------------------------------------------------------------
void Mapper118::vram_change_hook(uint16_t vram_address) {
	mapper_->vram_change_hook(vram_address);
}
